<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>变频器设备管理(格力)</title>
	<meta name="viewport"  content="width=device-width, initial-scale=1">
	<link rel="stylesheet" type="text/css" href="${path}/resource/plugins/bootstrap/css/bootstrap.min.css">
  	<link rel="stylesheet" type="text/css" href="${path}/resource/css/ysrmain.css">
	<link rel="stylesheet" type="text/css" href="${path}/resource/css/gzfx.css">
	<link rel="stylesheet" type="text/css" href="${path}/resource/css/allEquipment.css">
	<link rel="stylesheet" type="text/css" href="${path}/resource/css/myLayer.css">
	<link rel="stylesheet" type="text/css" href="${path}/resource/plugins/date/bootstrap-datetimepicker.min.css" >
	<script src="${path}/resource/plugins/jQuery/jquery-2.2.3.min.js"></script>
	<script type="text/javascript" src="${path}/resource/plugins/bootstrap/js/bootstrap.min.js"></script>
		<script src="${path}/resource/plugins/date/bootstrap-datetimepicker.min.js" charset="UTF-8"></script>
	<script src="${path}/resource/plugins/date/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
	<script type="text/javascript" src="${path}/resource/js/echarts.min.js"></script>	
	<script type="text/javascript"></script>
	<style type="text/css">
	.now-error{border-top-left-radius: 5px;border-bottom-left-radius: 5px;color:#fff;border:1px solid #3399b7;padding:4px 10px;z-index: 1000;display: inline-block;background:linear-gradient(to bottom, rgba(4, 188, 236, 0.6) 0%,rgba(255, 255, 255, 0.1) 50%,rgba(255, 255, 255, 0) 51%,rgba(4, 188, 236, 0.6) 100%)}
	.history-error{border-top-right-radius: 5px;border-bottom-right-radius: 5px;color:#fff;padding:4px 10px;border:1px solid #3399b7}
	.showAddress{padding: 2px 5px;background: #03a9f4;color: #fff;box-shadow: 0 0 2px #fff;cursor: pointer}
	.set{padding: 2px 5px;background: #03a9f4;color: #fff;box-shadow: 0 0 2px #fff;cursor: pointer}
	.layer{position:absolute;top:0;width:100%;height:100%;left:0;background: rgba(0,0,0,0.8);;z-index:100;display:none}
		.layer-bg{position:absolute;width:50%;height:500px;top:0;bottom:0;left:0;right:0;margin:auto;color:#fff;}				
	       .layer-head{border: 1px solid #337ab7;letter-spacing: 3px;color:#fff;height:50px;line-height:50px;font-size:2rem;padding:0 30px;border-top-right-radius: 5px;border-top-left-radius: 5px;}
		   		.layer-head::after{top:20px}
		   		.layer-head>a{cursor: pointer;height: 30px;display: inline-block;width: 40px;text-align: center;float: right;position: relative;right: -10px;top: 11px;line-height: 25px;font-size: 30px;}
		   		.layer-head>a:hover{color:#3399b7;}
		   .layer-body{border: 1px solid #337ab7;padding:30px 40px;height:90%;border-bottom-right-radius: 5px;border-bottom-left-radius: 5px;color:#333;background: rgba(238, 238, 238, 0.3);}
				.layer-msg{width:50%;float:left;height:95%;border-right: 2px solid #3399b7;}
				.layer-analyse{width:50%;float:right;height:100%;}
			 		.analyse-img{margin:10px;height:50%;border-bottom:2px dotted #3399b7}
			 	    .analyse-span{margin:10px;height:40%;}
	
	.search-input2 .search-btn{ height: 34px;width: 34px;border: 2px solid #012e67;background-position: 0.2em;}
	.center{float: left;width: 300px;height: 400px;background: rgba(33, 150, 243, 0.22);border-radius: 5px}
	.layer .table-striped>tbody tr:first-child {background:rgba(255,255,255,0.5);border-bottom:0}
	.selected{background:#2196F3 !important; }
	.btnlist{float: right;width:200px;height:400px; display: flex;justify-content: space-around;align-items: center;flex-direction: column;}
	.add-btn2 , .with-btn{ color: #fff;width: 50px; height: 50px;background: #2196F3;border-radius: 50%;text-align: center;line-height: 50px;box-shadow: 0px 0px 10px #fff;cursor: pointer}
	
	/*隐藏地图版权信息*/
	.anchorBL{display:none;}
	</style>
</head>
<body> 
	 
	<!-- 头部 -->
	<!-- 开始 -->
	<jsp:include page="./top_nav.jsp"></jsp:include>
	<!-- 头部结束 -->
    <!-- 右侧内容区域 -->
    <div class="right-content  container-fluid">
    	<div class="row ">
	    	<div class="layer1" >
	    		<!-- 主要图表区域 -->
	    		<div class=" row right-nav">
		    			<div class="title-name">
		    				<span>变频器设备管理</span>
		    				
		    			</div>
		    			<div class=" right nav-over padding-r-1  ">
<%-- 		    				 	<a href="${path}/monitor/redirect/equipInput" class="add-a">新增</a> --%>
		    				         <button class=" search-btn float-r" type="button" onclick="search();"></button>
						      <input id="require" type="text" placeholder="请输入检索的故障信息" class="back-m1 search-input float-r search back-m1">					      										      			
		    			</div>	    			
		    	</div>	
			    <!-- Table -->
			    <div class="table-div content-img">
			      <a class="now-error" href="${path}/monitor/redirect/equipManage">4G模块</a><a class="history-error" href="javascript:void(0)">格&nbsp;&nbsp;&nbsp;力</a><br>	
				  <table id="listtable" class="table table-striped " style="font-size: 13px">
				  	  <tr>
						  <th>变频器序列号</th>					 
						  <th>设备位置</th>
						  <th>参数配置</th>
						  <th>详细</th>
						  <th>删除</th>
					  </tr>
					  <tr>
						  <td><a class="color-w" href="<%=path%>/manage/redirect/allEquip/faultAnalysis?serialNum=0181413c">0181413c</a></td>
						  <td><span class="showAddress">查看位置</span></td>
						  <td><span class="set">配置</span></td>
						  <td><img class="table-icon" alt="" src="${path}/resource/images/sbmsg.png"></td>
						  <td><img class="table-icon" alt="" src="${path}/resource/images/sbsc.png"></td>
					  </tr>
					  <tr>
						  <td><a class="color-w" href="<%=path%>/manage/redirect/allEquip/faultAnalysis?serialNum=0181413c">0181413c</a></td>
						  <td><span class="showAddress">查看位置</span></td>
						  <td><span class="set">配置</span></td>
						  <td><img class="table-icon" alt="" src="${path}/resource/images/sbmsg.png"></td>
						  <td><img class="table-icon" alt="" src="${path}/resource/images/sbsc.png"></td>
					  </tr>
					  <tr>
						  <td><a class="color-w" href="<%=path%>/manage/redirect/allEquip/faultAnalysis?serialNum=0181413c">0181413c</a></td>
						  <td><span class="showAddress">查看位置</span></td>
						  <td><span class="set">配置</span></td>
						  <td><img class="table-icon" alt="" src="${path}/resource/images/sbmsg.png"></td>
						  <td><img class="table-icon" alt="" src="${path}/resource/images/sbsc.png"></td>
					  </tr>
					  <tr>
						  <td><a class="color-w" href="<%=path%>/manage/redirect/allEquip/faultAnalysis?serialNum=0181413c">0181413c</a></td>
						  <td><span class="showAddress">查看位置</span></td>
						  <td><span class="set">配置</span></td>
						  <td><img class="table-icon" alt="" src="${path}/resource/images/sbmsg.png"></td>
						  <td><img class="table-icon" alt="" src="${path}/resource/images/sbsc.png"></td>
					  </tr>
				  </table>
			    </div>
			    <!-- 分页 -->
			    <div id="fenye" class="pagers">
			  	  <nav class="float-r padding-3">
			  	    <ul class="pagination">
			  	      <li id="goPrev"><a href="javascript:void(0);">&laquo;</a></li>
				      <li class="active yema"><a href="javascript:void(0);">1</a></li>
				      <li class="yema"><a href="javascript:void(0);">2</a></li>
				      <li id="goNext"><a href="javascript:void(0);">&raquo;</a></li>
			  	    </ul>
			  	  </nav>
			    </div>
			</div>
			<!--删除弹出层-->
			<div class="layer2 layer-remove">
				<div class="layer-content">
					<div class="layer-msg">
						<div>确定删除该条记录?
						</div>
					</div>
					<div class="layer-btn">
						<div class="sure2 delBtn" id="delSure"><a href="javascript:void(0)" class="color-w">确定</a></div>
						<div class="cancel2 delBtn" id="delCancel"><a href="javascript:void(0)" class="color-w">取消</a></div>
					</div>					
				</div>
			</div>
			<!--详情弹出层-->
			<div class="layer2">
				<div class="layer-content">
				<form id="dataForm" class="input-form">
					<div class="layer-top">
						<div>
							变频器<span id="serialNum">00851125</span>详细信息
						</div>
					</div>
					<input type="hidden" name="serialNum">
					<div class="layer-body">
						<div class="div-group4">
							<label class="">所在省份:</label>
							<select id="province" name="province">
					    		<option value=""></option>
					    	</select>
						</div>
						<div class="div-group4">
							<label>所在城市:</label>
							<select id="cityArea" name="cityArea">
					    		<option value=""></option>
					    	</select>
						</div>
						<div class="div-group4">
							<label>位置经度:</label>
							<input id="jD" name="jD" type="text">
						</div>
						<div class="div-group4">
							<label>位置纬度:</label>
							<input id="wD" name="wD" type="text">
						</div>
						<div class="div-group4">
							<label>设备型号:</label>
							<select id="powerLevelType" name="powerLevelType">
					    		<option value=""></option>
					    	</select>
						</div>
						<div class="div-group4">
							<label>投运日期:</label>
							<input name="operationDate" type="text" readonly="readonly" data-link-format="yyyy-mm-dd" data-link-field="dtp_input2"  class="form_date  input-text" id="datetimepicker2" data-date-format="yyyy-mm-dd ">
			     			<span class=" span-date"><span class="glyphicon glyphicon-calendar"></span></span>
						</div>
						
						<div class="div-group8">
							<label>详细地址:</label>
							<input name="locationDetail" type="text">
						</div>
						<div class="div-group4">
							<label>软件版本:</label>
							<input name="softwareVersion" type="text">
						</div>
						<div class="div-group4">
							<label>用户姓名:</label>
							<input name="userName" type="text">
						</div>
						<div class="div-group4">
							<label>用户电话:</label>
							<input name="userTel" type="text">
						</div>
						<div class="div-group4">
							<label>用户邮箱:</label>
							<input name="userEmail" type="text">
						</div>
						<div class="div-group4">
							<label>路由序号:</label>
							<input name="fourGRouteSeriNum" type="text">
						</div>
						<div class="div-group4">
							<label>路由型号:</label>
							<input name="fourGRouteType" type="text">
						</div>
						<div class="div-group4">
							<label>路由卡号:</label>
							<input name="fourGRouteSIMCard" type="text">
						</div>
						<div class="div-group4">
							<label>IP隧道值:</label>
							<input name="tunnelEndIP" type="text">
						</div>																		
						<label class="label-text">故障现象:</label><br>
						<textarea name="factoryCommission" class="textarea" rows="" cols="" placeholder="正常"></textarea><br>	
						<div class="foot">
							<a class="save" href="javascript:void(0)" onclick="update()">保存</a>
							<a class="cancel" href="javascript:void(0)">取消</a>	
						</div>		
					</div>
				</form>
				</div>
			</div>
			<!-- 设备位置弹窗 -->
			<div class="layer" id="layer" style="display: none;">
				<div class="layer-bg">
					<div class="layer-head point foot-name">
						<span>设备位置:</span>
						<a class="off-layer" id='off-layer'>x</a>
					</div>
					<div  class="layer-body">	
						<div id="locationMap" style="width: 100%; height: calc(100% - 26px);display:block"></div>     				    
					</div>
				</div>
			</div>
			<!-- 配置弹窗 -->
			<div class="layer" id='layer-set' style="display: none;">
				<div class="layer-bg">
					<div class="layer-head point foot-name">
						<span>设备配置:</span>
						<a class="off-layer" id='off-set'>x</a>
					</div>
					<div  class="layer-body">	
						<div class="layer-main">
							<div class="center">
					    		<div class="input-group search-input2 ">
							      <input id="allListRequire" type="text"  class="form-control float-r search back-m1 color-w">
							      <span class="input-group-btn">
							        <button class="btn  search-btn" type="button" onclick="allListSearch();"></button>
							      </span>
								</div>
								<div class="left table-head color-w">
									<span >序列号</span><span class="float-r">运行状态</span>
								</div>
								<div class="ul-div">
			
									<table id="listtable2" class="table table-striped color-w">
									  
									  <tr>
									  	<td class="left"><a class="color-w" href="<%=path%>/manage/redirect/allEquip/faultAnalysis?serialNum=0181413C">0181413C</a></td>
									  	<td class="right">正常</td>
									  </tr>	
									  <tr>
									  	<td class="left"><a class="color-w" href="<%=path%>/manage/redirect/allEquip/faultAnalysis?serialNum=0181413C">0181413C</a></td>
									  	<td class="right">正常</td>
									  </tr>	
									  <tr>
									  	<td class="left"><a class="color-w" href="<%=path%>/manage/redirect/allEquip/faultAnalysis?serialNum=0181413C">0181413C</a></td>
									  	<td class="right">正常</td>
									  </tr>														 							 
									</table>
								</div>
							</div>
							<div  class="btnlist">
								<div class="with-btn" onClick="guanlian();">关联</div>
								<div class="add-btn2" onClick="xinzeng();">新增</div>
							</div>
		     			</div>  		     					     				    
					</div>
				</div>
			</div>
		</div>
    </div>

	


	
</body>
<script type="text/javascript" src="${path}/resource/js/webSocketConf.js"></script>	
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=ZUONbpqGBsYGXNIYHicvbAbM"></script>
<script type="text/javascript">
$(function(){
	$(".menu-left").children("dl").eq(1).addClass("dl-active");
	
	attrYemaSearch();
	//loadSelect();
})
//加载下拉框
function loadSelect() {
	$.ajax({
		type : 'POST',
		url : '<%=path%>/manage/initopt',
		data : {
			opttype : 'province'
		},
		dataType : 'json',
		async : false,
		success : function(result) {
			if(result.status == 'OK') {console.log(result);
				var html = '<option value="">——— 请选择 ———</option>';
				var ops = eval("(" + result.data.province + ")");
				$.each(ops, function(i) {
					html += ops[i].value;
				});
				$('#province').html('');
				$('#province').append(html);
			} else {
				console.error("获取下拉框数据失败！");
			}
		},
		error : function() {
			console.error("系统错误！");
		}
	});
	$.ajax({
		type : 'POST',
		url : '<%=path%>/manage/initopt',
		data : {
			opttype : 'powerLevel'
		},
		dataType : 'json',
		async : false,
		success : function(result) {
			if(result.status == 'OK') {console.log(result);
				var html = '<option value="">——— 请选择 ———</option>';
				var ops = eval("(" + result.data.powerLevel + ")");
				$.each(ops, function(i) {
					html += ops[i].value;
				});
				$('#powerLevelType').html('');
				$('#powerLevelType').append(html);
			} else {
				console.error("获取下拉框数据失败！");
			}
		},
		error : function() {
			console.error("系统错误！");
		}
	});
}
//选择省份
$('#province').change(function() {
	if($(this).val() != "" && $(this).val() != null) {
		var val = $(this).val();
		$.ajax({
			type : 'POST',
			url : '<%=path%>/manage/sltoptupdate',
			data : {
				opttype : 'cityArea',
				actval : val
			},
			dataType : 'json',
			async : false,
			success : function(result) {
				if(result.status == 'OK') {console.log(result);
					var html = '<option value="">——— 请选择 ———</option>';
					var ops = eval("(" + result.data.cityArea + ")");
					$.each(ops, function(i) {
						html += ops[i].value;
					});
					$('#cityArea').html('');
					$('#cityArea').append(html);
				} else {
					console.error("获取下拉框数据失败！");
				}
			},
			error : function() {
				console.error("系统错误！");
			}
		});
	} else {
		$('#cityArea').html('<option value=""></option>');
	}
});
/*详细信息弹窗  */
$(function(){
// 	$(".detailedMsg").click(function(){
// 		$(".layer2").show();
// 	})
	
	$(".cancel").click(function(){
		$(".layer2").hide();
	})	
	
	/*设备位置  */
	$("#listtable").on("click",".showAddress", function() {
		
		$('#layer').show();
	});
	$("#off-layer").click(function(){
		$('#layer').hide();
	})
	/*参数配置*/
	$('.set').click(function(){
		$('#layer-set').show();
	})
	
	$("#off-set").click(function(){
		$('#layer-set').hide();
	})
})

var size = 1;
var curPageNO = 1;
function search() {
	$.ajax({
		type : 'POST',
		url : '<%=path%>/manage/managernewdevlist',
		data : {
			require : $("#require").val(),
			pageSize : 10,
			curPageNO : curPageNO
		},
		dataType : 'json',
		async : false,
		success : function(result) {
			if(result.status == "OK") {
				$('#listtable').text('');
				var html = "<tr><th>变频器序列号</th><th>设备位置</th><th>参数配置</th><th>详细</th><th>删除</th></tr>";
				if(result.data.list == "[null]") {
					
				} else { 
					size = result.data.size;
					var list = eval("(" + result.data.list + ")");
					$.each(list, function(i){
<%-- 						var href = "<%=path%>/manage/redirect/allEquip/faultAnalysis?serialNum="+list[i].serialNum; --%>
						html += '<tr><td>'+list[i].devId+'</td>'+
								'<td><span class="showAddress" onClick="initLocationMap(\''+list[i].jd+'\',\''+list[i].wd+'\');">查看位置</span></td>'+
							  	'<td><span class="set" onClick="doSet(\''+list[i].devId+'\');">配置</span></td>'+
							  	'<td><img class="table-icon" alt="" src="${path}/resource/images/sbmsg.png"></td>'+
							  	'<td><img class="table-icon" alt="" src="${path}/resource/images/sbsc.png"></td></tr>';
					  
					});
				}
				$('#listtable').append(html);
				/*设备位置  */
// 				$("#listtable").on("click",".showAddress", function() {
// 					initLocationMap();
// 				});
				$("#off-layer").click(function(){
					$('#layer').hide();
				})
				/*参数配置*/
// 				$('.set').click(function(){
// 					$('#layer-set').show();
// 				})
				
				$("#off-set").click(function(){
					$('#layer-set').hide();
				})
			}
		},
		error : function() {
			//alert("系统错误！");
		}
	});
}
//加载地图
function initLocationMap(jd,wd) {
	$('#layer').show();
	
	// 百度地图API功能
	map = new BMap.Map("locationMap", {enableMapClick:false}); //构造底图时，关闭底图可点功能
	map.setMapType(BMAP_NORMAL_MAP); //设置默认为卫星图
	var point = new BMap.Point(jd,wd);
	map.centerAndZoom(point, 13);
	//map.setMinZoom(8);
	map.disableDragging(); //禁止拖拽
	map.disableScrollWheelZoom(); //禁用滚轮缩放
	//map.enableDragging(); //开启拖拽
	//map.enableScrollWheelZoom(); //允许滚轮缩放
	var marker = new BMap.Marker(point);
	map.addOverlay(marker);
}

var devId;

var listWebSocket = null;
var livedata;
// var message = "[{\"serialnum\":\"all\",\"signalnames\":[\"breakerstate\",\"runninglight\",\"faultlight\"]}]";//调用参数
var message = "[{\"serialnum\":\"all\",\"signalnames\":[\"c196\",\"c78\",\"c77\"]}]";//调用参数
	//获取设备列表实时数据
if ("WebSocket" in window) {
	listWebSocket = new WebSocket(webSocketUrl);
	console.log("建立实时连接！");
} else if ("MozWebSocket" in window) {
	listWebSocket = new MozWebSocket(webSocketUrl);
	console.log("建立实时连接！");
} else {
	alert("浏览器不支持！");
}
listWebSocket.onerror = function() {
	alert("无法建立实时连接！");
};
listWebSocket.onopen = function(event) {
	listWebSocket.send(message);
	console.log("open");
};
listWebSocket.onmessage = function() {
	if(event.data.length>2){
		livedata=event.data;
		//tableinitinfo();
		allListSearch();
		listWebSocket.close();
	}else{
		console.log("resend...");
		listWebSocket.send(message);
	}		
};
listWebSocket.onclose = function() {
};
window.onbeforeunload = function() {
	listWebSocket.close();
};
//加载配置弹出框
function doSet(selectdevId) {
	$('#layer-set').show();
	devId = selectdevId;
	
    
}
//加载所有设备列表
function allListSearch() {
	$.ajax({
		type : 'POST',
		url : '<%=path%>/manage/seconddevTotal',
		data : {
			livedata : livedata,
			require : $("#allListRequire").val()
		},
		dataType : 'json',
		async : false,
		success : function(result) {
			if(result.status == "OK") {
				$('#listtable2').text('');
				//var html = "<tr><th>变频器序列号</th><th>安装位置</th><th>投运时间</th><th>工作状态</th></tr>";
				var html = "";
				$.each(result.data, function(i){
					html += '<tr><td class="left">'+result.data[i].serialNum +
							'</td><td class="right">'+result.data[i].state +'</td></tr>';
				});
				$('#listtable2').append(html);
				
				$("#listtable2").on("click",'tr',function(){
		 			if($(this).hasClass('selected')){
		 				$(this).removeClass('selected');					 				
		 			}else{
		 				$("#listtable2 tr").removeClass('selected');
		 				$(this).addClass('selected');
		 			} 			
		 		})
			}
		},
		error : function() {
			//alert("系统错误！");
		}
	})
}

function guanlian() {
	var selectedtr = $("#listtable2 tr.selected");
	var serialNumtext = selectedtr[0].children[0].textContent;
	console.log(serialNumtext);
	$.ajax({
		type : 'POST',
		url : '<%=path%>/manage/managerdevdetail',
		data : {
			serialNum : serialNumtext
		},
		dataType : 'json',
		async : false,
		success : function(result) {
			if(result.status == 'OK') {
				var data = result.data;
				data.devId = devId;
				console.log(data);
				$.ajax({
					type : 'POST',
					url : '<%=path%>/monitor/managerdevAdd',
					data : data,
					dataType : 'json',
					async : false,
					success : function(result) {
						if(result.status == 'OK') {
							if(result.data != null && result.data == "true") {
								alert("关联成功！");
								window.location.href = '<%=path%>/monitor/redirect/equipManageGree';
							} else {
								alert("关联失败！");
							}
						} else {
							alert("关联失败！");
						}
					}
				});
			} else {
				console.error("获取设备详情数据失败！");
			}
		},
		error : function() {
			console.error("系统错误！");
		}
	});
}

function xinzeng() {
	window.location.href = "<%=path%>/monitor/redirect/equipInput";
}

//设备详情
function devdetail(serialNum) {
	if(serialNum != undefined && serialNum != "") {
		$("#serialNum").text(serialNum);
		$('input[name="serialNum"]').val(serialNum);
		$.ajax({
			type : 'POST',
			url : '<%=path%>/manage/managerdevdetail',
			data : {
				serialNum : serialNum
			},
			dataType : 'json',
			async : false,
			success : function(result) {
				if(result.status == 'OK') {console.log(result);
					
					$('#powerLevelType').val(result.data.powerLevelType);
					$('#province').val(result.data.province);
					//devAddInfo.setCityArea(request.getParameter("cityArea"));
					$('#jD').val(result.data.jD);
					$('#wD').val(result.data.wD);
					$('input[name="operationDate"]').val(result.data.operationDate);
					$('input[name="locationDetail"]').val(result.data.locationDetail);
					$('textarea[name="factoryCommission"]').val(result.data.factoryCommission);
					$('input[name="softwareVersion"]').val(result.data.softwareVersion);
					$('input[name="fourGRouteSeriNum"]').val(result.data.fourGRouteSeriNum);
					$('input[name="fourGRouteType"]').val(result.data.fourGRouteType);
					$('input[name="fourGRouteSIMCard"]').val(result.data.fourGRouteSIMCard);
					$('input[name="tunnelEndIP"]').val(result.data.tunnelEndIP);
					$('input[name="userTel"]').val(result.data.userTel);
					$('input[name="userEmail"]').val(result.data.userEmail);
					$('input[name="userName"]').val(result.data.userName);
				
					if(result.data.province != undefined && result.data.province != "") {
						$.ajax({
							type : 'POST',
							url : '<%=path%>/manage/sltoptupdate',
							data : {
								opttype : 'cityArea',
								actval : result.data.province
							},
							dataType : 'json',
							async : false,
							success : function(result2) {
								if(result2.status == 'OK') {console.log(result2);
									var html = '<option value="">——— 请选择 ———</option>';
									var ops = eval("(" + result2.data.cityArea + ")");
									$.each(ops, function(i) {
										html += ops[i].value;
									});
									$('#cityArea').html('');
									$('#cityArea').append(html);
									$('#cityArea').val(result.data.cityArea);
								} else {
									console.error("获取下拉框数据失败！");
								}
							},
							error : function() {
								console.error("系统错误！");
							}
						});
					}
				} else {
					console.error("获取设备详情数据失败！");
				}
			},
			error : function() {
				console.error("系统错误！");
			}
		});
	}
	$(".layer2").show();
}
$(".cancel").click(function(){
	$(".layer2").hide();
});
function update() {
	$.ajax({
		type : 'POST',
		url : '<%=path%>/monitor/managerdevUpdate',
		data : $('#dataForm').serialize(),
		dataType : 'json',
		async : false,
		success : function(result) {
			if(result.status == 'OK') {
				if(result.data != null && result.data == "true") {
					alert("修改成功！");
					$(".layer2").hide();
					attrYemaSearch();
<%-- 					window.location.href = '<%=path%>/monitor/redirect/equipManage'; --%>
				} else {
					alert("修改失败！");
				}
			}
		}
	});
}

//设备删除
function devdelete(serialNum) {
	$(".layer-remove").show();
	$(".delBtn").unbind('click');
	
	$(".delBtn").bind('click',function(){
		if(this.id == "delSure") {
			$.ajax({
				type : 'POST',
				url : '<%=path%>/monitor/managerdevdelete',
				data : {
					serialNum : serialNum
				},
				dataType : 'json',
				async : false,
				success : function(result) {
					if(result.status == "OK") {
						console.log(result.data);
						if(result.data == "true") {
							alert("删除成功");
							attrYemaSearch();
						} else {
							alert("删除失败");
						}
					}
				},
				error : function() {
					//alert("系统错误！");
				}
			});
		}
		$(".layer-remove").hide();
	});
}

//点击页码
function attrYemaSearch() {
	curPageNO = 1;
	search();
	//$('.pagination').html('');
	$('.pagination').html('<li id="goPrev"><a href="javascript:void(0);">&laquo;</a></li>'+
	    '<li id="firstyema" class="active yema"><a href="javascript:void(0);">1</a></li>'+
	    '<li id="goNext"><a href="javascript:void(0);">&raquo;</a></li>');
	if(size > 10) {
		var html = '';
		var yemaToal = (size/10)+1;
		for(var i=2; i<yemaToal; i++) {
			html += '<li class="yema"><a href="javascript:void(0);">'+i+'</a></li>'
		}
		$('#firstyema').after(html);
	}
	attrYeMa();
}
function attrYeMa() {
	$('.yema').click(function() {
		console.log("a");
		$('.yema').removeClass("active");
		$(this).addClass("active");
		curPageNO = $(this).children('a').text();
		search();
	});
	$('#goPrev').click(function() {
		var prevyema = $(this).nextAll('.active').prev('.yema');
		if(prevyema != null && prevyema.length > 0) {
			$(this).nextAll('.active').removeClass("active");
			prevyema.addClass("active");
			curPageNO = prevyema.children('a').text();
			search();
		}
	});
	$('#goNext').click(function() {
		var nextyema = $(this).prevAll('.active').next('.yema');
		if(nextyema != null && nextyema.length > 0) {
			$(this).prevAll('.active').removeClass("active");
			nextyema.addClass("active");
			curPageNO = nextyema.children('a').text();
			search();
		}
	});
}
	/*初始化时间控件*/
	$(function(){
		$(".span-date").click(function(){
			$(this).prev().focus();
		});
		$('.form_date').datetimepicker({
		    language:  'zh-CN',
		    weekStart: 1,
		    todayBtn:  1,
			autoclose: 1,
			todayHighlight: 1,
			startView: 2,
			minView: 2,
			forceParse: 0,
			maxView:4
		});
	})
	/*弹窗表格选中*/
	/*报告发送选中时间*/
 	$(function(){
//  		$("#listtable2").on("click",'tr',function(){
//  			if($(this).hasClass('selected')){
//  				$(this).removeClass('selected');
 															 				
//  			}else{
//  				$("#listtable2 tr").removeClass('selected');
//  				$(this).addClass('selected');
 				
 				
 				
//  			} 			
//  		})
 	})

</script>
</html>